// pages/mine/seniority/seniority.js
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    array:[1,2,3,4,5,6,7,8,9]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: app.globalData.phpUrl + 'user/api',
      method: 'POST',
      data: { api_name: 'ranking_list', openid: options.openOId },
      success: function (d) {
        that.setData({ seniority: d.data.data, userInfo: app.globalData.userInfo, openid: options.openOId});
        console.log(that.data.seniority);
        wx.hideLoading()
      }
    })
  },

  switchChange:function(e){
    var that = this;
    wx.showLoading({
      title: '设置中...',
    });
    wx.request({
      url: app.globalData.phpUrl + 'user/api',
      method: 'POST',
      data: { api_name: 'is_show', openid: that.data.openid },
      success: function () {
        wx.request({
          url: app.globalData.phpUrl + 'user/api',
          method: 'POST',
          data: { api_name: 'ranking_list', openid: that.data.openid },
          success: function (d) {
            that.setData({ seniority: d.data.data, userInfo: app.globalData.userInfo });
            wx.hideLoading()
          }
        })
      }
    })
  },

  goAnser:function(){
    console.log('jjj')
    wx.switchTab({
      url: '../../index/index'
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

})